home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1997-06-04 | 6.0 KB | 265 lines | [ DIRC/PTM2]
/**************************************** * * * ProTERM/Mac Resident Macro Library * * * * Version 1203 Updated 05/01/97 * * * ****************************************/ /* This file is periodically updated by InTrec Software. As such, modifications to this file are not advised (because it becomes very difficult to move your changes to new versions of this file). Instead, make your changes to the Resident User # (where # is a number) file instead. That way, even if you get an updated version of Resident Library, your own personal macros remain unchanged within the Resident User # file. The Resident User # files have precedence over the Resident Library file. Therefore, if you define duplicate routines or variables in the Resident User # files, they will be used instead of those in the Resident Library file. */ // special code to allow direct execution FUNC main() { EXTERN(PREF_GET("mac1"),main(1)); RETURN; } // make the library resident FUNC startup() { SHARED STR _RLIB = "1022"; RESIDENT("",0,#KeyAccess+#LibAccess); RETURN; } /***********************************************************************/ /* Start of Library Macros */ /***********************************************************************/ /* cmd_find(win_active(0),"resu^clt",0,0,0); */ // find text FUNC cmd_find(INT win, STR find, INT from, INT uppr, INT dirc) { STR result,from0,uppr0,dirc0; from0 = "start"; IF (from == 1) { from0 = "curs" } uppr0 = "ignore"; IF (uppr == 1) { uppr0 = "exact" } dirc0 = "forward"; IF (dirc == 1) { dirc0 = "reverse" } result = UI_CMD('^ cmd=find wind=%d find=&%*2s from=%s case=%s dir=%s ',win,find,from0,uppr0,dirc0); RETURN(UI_NUM("retn",0,result)) } // replace text FUNC cmd_replace(INT win, STR find, STR repl, INT from, INT uppr, INT dirc) { STR result,from0,uppr0,dirc0; from0 = "start"; IF (from == 1) { from0 = "curs" } uppr0 = "ignore"; IF (uppr == 1) { uppr0 = "exact" } dirc0 = "forward"; IF (dirc == 1) { dirc0 = "reverse" } result = UI_CMD('^ cmd=find wind=%d find=&%*2s repl=&%*2s from=%s case=%s dir=%s ',win,find,repl,from0,uppr0,dirc0); RETURN(UI_NUM("retn",0,result)) } // start an ascii receive FUNC cmd_rcvasc(INT ses, STR file, INT line, INT ctrl, INT bit8) { STR result; IF (!ses) { ses = WIN_FIND("","TERM") } result = UI_CMD(' cmd=capt wind=%d file="%s" #save mode=%d ctrl=%d bit8=%d ',ses,file,1+(line>0),(ctrl>0),(bit8>0)); RETURN(UI_NUM("retn",0,result)); } // use uuundo to decode a file FUNC cmd_uuundo(STR file) { INT run; run = IS_RUN("uuUN"); IF (!run) { F_LAUNCH(FN_TYPE("uuUN")) } UI_CMD(' cmd=apvt appl=@uuUN clas=@aevt kind=@odoc aeou="rqfi----file" file="%s" ',file); IF (!run) { UI_CMD("cmd=apvt appl=@uuUN clas=@aevt kind=@quit") } RETURN; } // send a file with ascii FUNC cmd_sndasc(INT ses, STR file, STR pmt, INT cp, INT lp, INT wid, INT blk) { STR result; STR cp0,lp0; IF (!IS_FILE(file)) { RETURN(0) } IF (!ses) { ses = WIN_FIND("","TERM") } IF (IS_STR(cp)) { cp0 = cp } IF (IS_NUM(cp)) { cp0 = STR_NUM(cp) } IF (IS_STR(lp)) { lp0 = lp } IF (IS_NUM(lp)) { lp0 = STR_NUM(lp) } result = UI_CMD('^ {onln cmd=session ptr=%d} {from cmd=stream srcf="%s" +buf dstt=cmd conv=dot} cmd=ascii strm=.from.strm sess=.onln.sess prompt="%s" char="%s" line="%s" width="%d" blank="%d" ',ses,file,pmt,cp0,lp0,wid,(blk>0)); RETURN(UI_NUM("wind",0,result)); } // tell finder to update folder FUNC cmd_osupdt(STR folder) { RETURN(UI_NUM("retn",0,UI_CMD(' cmd=apvt appl=@MACS clas=@fndr kind=@fupd aeou="rqfi----file" file="%s" aein="opnuerrnerrn" ',folder))); } // tell finder to clean-up folder/file FUNC cmd_osclean(STR folder) { RETURN(UI_NUM("retn",0,UI_CMD(' cmd=apvt appl=@MACS clas=@fndr kind=@fclu aeou="rqfi----file" file="%s" aein="opnuerrnerrn" ',folder))); } // disconnect from the service FUNC cmd_hang(INT win) { // if passed 0, find the window IF (win == 0) { win = NUM_LONG(SES_GET(0,"WIN")); } // do the hangup IF (win != 0) { WT(0); UI_CMD(' {onln cmd=sess ptr=%d} cmd=online sess=.onln.sess opt=disc +status {**** cmd=msg wind=%d msg=CLOS} ',win,win); } RETURN(0); } // start another macro running (in its own thread space) FUNC cmd_macro(STR fname, INT ses) { INT x; INT win; STR cli; STR arg; // build the CLD for the macro exec arg = "{term cmd=session #find}"; IF (ses != -1) { arg = STR_FORMAT("{term cmd=session ptr=%u}", ses); } cli = STR_FORMAT("%s cmd=macro file=&%*2s sess=.term.sess", arg, fname); // add on the macro arguments x = 3; WHILE (x <= ARGC()) { arg = ""; IF (IS_NUM(ARGV(x))) { arg = STR_FORMAT(" parm=%d", ARGV(x)); } IF (IS_STR(ARGV(x))) { arg = STR_FORMAT(" parm=&%*2s", ARGV(x)); } cli = cli + arg; x = x + 1; } // start execing macro and return window ident win = UI_NUM("wind",0,UI_CMD(cli)); RETURN(win); } // make a ppp connection FUNC ppp_conn() { INT err; STR aevt; // send the connect apple event aevt=ui_cmd('cmd=apvt appl=@FNDR clas=@netw kind=@RAco aein="opnuerrnerrn"'); // extract the error code err = UI_NUM("errn",0,aevt); printf("aevt=%s^m",aevt); printf("err=%d^m",err); // return error code RETURN(err); } // disconnect ppp session FUNC ppp_disc() { INT err; STR aevt; // send the connect apple event aevt=ui_cmd('cmd=apvt appl=@FNDR clas=@netw kind=@RAdc aein="opnuerrnerrn"'); // extract the error code err = UI_NUM("errn",0,aevt); // return error code RETURN(err); } // return ppp status FUNC ppp_stat() { INT err; INT idx; INT len; STR aevt; STR stat; // send the connect apple event aevt=ui_cmd('cmd=apvt appl=@FNDR clas=@netw kind=@RAst aein="nutx----retn"'); // extract the status info stat = UI_STR("retn",0,aevt); // get index to connect info idx = STR_INDEX("RAmsTEXT",stat); IF (idx > 0) { len = NUM_LONG(STR_MID(stat,idx+8)); RETURN(STR_MID(stat,idx+12,len)); } // no status info available RETURN(""); }